package com.mldong.base;

import lombok.Data;

@Data
public class CommonResult<T> {
    private int code;
    private String msg;
    private T data;
    /**
     * 成功
     * @return
     */
    public static CommonResult success(Object data) {
        CommonResult result = new CommonResult();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(data);
        return result;
    }
    /**
     * 成功
     * @return
     */
    public static CommonResult success() {
        return success(null);
    }
    /**
     * 失败
     * @return
     */
    public static CommonResult fail(String msg) {
        return fail(99999999, msg);
    }
    /**
     * 失败
     * @return
     */
    public static CommonResult fail(int code,String msg) {
        CommonResult result = new CommonResult();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
